package com.zzz.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/*
 * @author zzr
 * @date: 2025/07/07  16:50
 * @description: 测试 GET 请求的乱码问题
 */
@WebServlet("/user")
public class UserServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 设置 content-type 响应头
        // 告诉浏览器以指定的 MIME 类型和 字符集 来解析响应体
        resp.setContentType("text/html;charset = UTF-8");
        resp.getWriter().write("你好 hello");
    }
}
